# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=arpon
pkgver=3.1
pkgrel=1
pkgdesc='A host-based solution to secure the ARP protocol and prevent MITM attacks via ARP spoofing or cache poisoning.'
arch=('x86_64' 'aarch64')
url='https://arpon.sourceforge.net/'
license=('custom')
depends=('libdnet' 'libnet' 'libpcap')
makedepends=('cmake' 'libdnet')
backup=('etc/conf.d/arpon')
groups=('blackarch' 'blackarch-defensive' 'blackarch-networking')
source=("https://github.com/Obsidian-Covenant/arpon/archive/refs/tags/$pkgver.tar.gz"
        "$pkgname"
        "$pkgname.conf.d")
sha512sums=('fb1dd338b7368c1b54d23ef30eed28d29396b60e7e7cba31b29970f6230248228e5f982f725def81ab7fc54fd66b2c60a77bee24ea306284315e1caef2ff641c'
            '0cd0114efd2f35fcf06ec91a56c5aca66adf13a7b25fbf82b2483489d040447d1a3a609f223f911ad1c407b321c6fbc22d32c9200f08fef2bbbf9ec391b7bb90'
            '75526a64be9ab7e6cc787dbff5cdb1e3d7c3b708fc3f9cc1712ea7b16181767aca4747a00c99f4bec6b0de0f86f131c76ec20e2ef7d24c2237c314df95dfc39d')

build() {
  cd "$pkgname-$pkgver"

  [ -d build ] || mkdir build

  cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
  cmake --build build
}

package() {
  cd "$pkgname-$pkgver/build"

  make DESTDIR="$pkgdir" install

  install -Dm 755 "$srcdir/$pkgname" "$pkgdir/etc/rc.d/$pkgname"
  install -Dm 644 "$srcdir/$pkgname.conf.d" "$pkgdir/etc/conf.d/$pkgname"
  install -Dm 644 ../LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  mv "$pkgdir/usr/sbin" "$pkgdir/usr/bin"
}

